﻿using System.Diagnostics.CodeAnalysis;
using OrderMicroService.Infrastructure.Repository.Common;
using OrderMicroService.Types.Types;

namespace OrderMicroService.Infrastructure.Repository
{
    public interface IAggregateManager<TAggregate, TIdentifier>
        where TAggregate : IAggregate<TIdentifier>
        where TIdentifier : IIdentifier
    {
        void Attach([NotNull] TAggregate aggregate);

        void Attach([NotNull] TAggregate aggregate, [NotNull] TIdentifier id);

        void Detach([NotNull] TAggregate aggregate);

        public TAggregate Find([NotNull] TIdentifier id);

        public EntityDiff DetectChanges([NotNull] TAggregate aggregate);

        public void Merge([NotNull] TAggregate aggregate);
    }
}